package com.iplant.mes.service.po.exc;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.general.CalendarTool;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * 返工返修
 */
@Slf4j
@DBBasePO(TableName = "exc_product_repair", Schemas = DBSchemas.MES, Name = false, Active = false,
        CheckName = {"Code"}, CodeAuto = true, CodePrefix = "RPR-{yyMM}-", CodeNum = 4)
public class EXCProductRepair extends BasePO {

    /**
     * 订单ID
     */
    @DBCondition
    @DBField
    public int OrderID = 0;
    /**
     * 订单号
     */
    @DBCondition
    @DBField
    public String OrderNo = "";

    @DBCondition
    @DBField
    public int ProductID = 0;

    @DBJoin(name = "Code", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public String ProductNo = "";

    @DBJoin(name = "Name", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public String ProductName = "";

    /**
     * 返工 1 /返修 2
     */
    @DBCondition
    @DBField(CheckValue = true)
    public int Type = 0;

    /**
     * 返修开始日期
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.geLe, ParamName = "StartDate", ParamName2 = "EndDate")
    @DBField
    public Calendar RepairStartDate = CalendarTool.getDate();

    /**
     * 预计返修完成日期
     */
    @DBField
    public Calendar PlanEndDate = CalendarTool.getDate();


    /**
     * 返修发起人
     */
    @DBCondition
    @DBField
    public int RepairID = 0;

    @DBJoinMulti(Name = "Name", TableName = "mbs_user", Schemas = DBSchemas.Basic, MainTableField =
            "RepairID")
    public String RepairName = "";

    /**
     * 返修确认人
     */
    @DBCondition
    @DBField
    public int ConfirmedID = 0;

    @DBJoinMulti(Name = "Name", TableName = "mbs_user", Schemas = DBSchemas.Basic, MainTableField =
            "ConfirmedID")
    public String ConfirmedName = "";

    /**
     * 返修完成日期
     */
    @DBField
    public Calendar RepairEndDate = CalendarTool.getDate();

    /**
     * 返修状态 1执行中  2部分完成（某些工件完成全部工序） 3全部完成（所有工件完成所有工序，或有些工件报废）  4确认关闭
     */
    @DBCondition
    @DBField
    public int Status = 0;

    /**
     * 返修执行备注  Description 单据描述
     */
    @DBField
    public String Remark = "";

    /**
     * 规则明细  一个规则明细内部只能包含一个序列号
     */
    @DBField(DefaultValue = "'[]'", CheckValue = true, isJson = true)
    public List<EXCPartPoint> PartPointList = new ArrayList<>();

    /**
     *返修工件集合
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.findInSet)
    @DBField
    public List<String> WorkpieceNoList = new ArrayList<>();

    @JsonProperty("OrderID")
    public int getOrderID() {
        return OrderID;
    }

    public void setOrderID(int orderID) {
        OrderID = orderID;
    }

    @JsonProperty("OrderNo")
    public String getOrderNo() {
        return OrderNo;
    }

    public void setOrderNo(String orderNo) {
        OrderNo = orderNo;
    }

    @JsonProperty("ProductID")
    public int getProductID() {
        return ProductID;
    }

    public void setProductID(int productID) {
        ProductID = productID;
    }

    @JsonProperty("ProductNo")
    public String getProductNo() {
        return ProductNo;
    }

    public void setProductNo(String productNo) {
        ProductNo = productNo;
    }

    @JsonProperty("ProductName")
    public String getProductName() {
        return ProductName;
    }

    public void setProductName(String productName) {
        ProductName = productName;
    }

    @JsonProperty("Type")
    public int getType() {
        return Type;
    }

    public void setType(int type) {
        Type = type;
    }

    @JsonProperty("RepairStartDate")
    public Calendar getRepairStartDate() {
        return RepairStartDate;
    }

    public void setRepairStartDate(Calendar repairStartDate) {
        RepairStartDate = repairStartDate;
    }

    @JsonProperty("PlanEndDate")
    public Calendar getPlanEndDate() {
        return PlanEndDate;
    }

    public void setPlanEndDate(Calendar planEndDate) {
        PlanEndDate = planEndDate;
    }

    @JsonProperty("RepairID")
    public int getRepairID() {
        return RepairID;
    }

    public void setRepairID(int repairID) {
        RepairID = repairID;
    }

    @JsonProperty("RepairName")
    public String getRepairName() {
        return RepairName;
    }

    public void setRepairName(String repairName) {
        RepairName = repairName;
    }

    @JsonProperty("ConfirmedID")
    public int getConfirmedID() {
        return ConfirmedID;
    }

    public void setConfirmedID(int confirmedID) {
        ConfirmedID = confirmedID;
    }

    @JsonProperty("ConfirmedName")
    public String getConfirmedName() {
        return ConfirmedName;
    }

    public void setConfirmedName(String confirmedName) {
        ConfirmedName = confirmedName;
    }

    @JsonProperty("RepairEndDate")
    public Calendar getRepairEndDate() {
        return RepairEndDate;
    }

    public void setRepairEndDate(Calendar repairEndDate) {
        RepairEndDate = repairEndDate;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("Remark")
    public String getRemark() {
        return Remark;
    }

    public void setRemark(String remark) {
        Remark = remark;
    }

    @JsonProperty("PartPointList")
    public List<EXCPartPoint> getPartPointList() {
        return PartPointList;
    }

    public void setPartPointList(List<EXCPartPoint> partPointList) {
        PartPointList = partPointList;
    }


    @JsonProperty("WorkpieceNoList")
    public List<String> getWorkpieceNoList() {
        return WorkpieceNoList;
    }

    public void setWorkpieceNoList(List<String> workpieceNoList) {
        WorkpieceNoList = workpieceNoList;
    }
}
